#ifndef __PLATFORM_PRINTF_H__
#define __PLATFORM_PRINTF_H__
#include <typescommon.h>
void systemPrintf(char *format, ...);
enum logLevelEnum
{
    logLevelFatal = 0,
    logLevelError,
    logLevelWarn,
    logLevelInform,
    logLevelDebug,
    logLevelTrace,
};
extern int MCU_XDATA_TYPE logLevelParam;
#if DEVICE_PLATFORM_CONFIGURE != DEVICE_PLATFORM_C51_MCU
#define printf_common(lev, fmt, lprt, ...)                                                                    \
    do                                                                                                        \
    {                                                                                                         \
        if (lev <= logLevelParam)                                                                             \
        {                                                                                                     \
            systemPrintf("[%u][%s][%s,%d]" fmt "\n", systemNowMs(), lprt, __FILE__, __LINE__, ##__VA_ARGS__); \
        }                                                                                                     \
    } while (0);
#define printffatal(fmt, ...) printf_common(logLevelFatal, fmt, "fat", ##__VA_ARGS__)
#define printerror(fmt, ...) printf_common(logLevelError, fmt, "err", ##__VA_ARGS__)
#define printwarn(fmt, ...) printf_common(logLevelWarn, fmt, "war", ##__VA_ARGS__)
#define printinform(fmt, ...) printf_common(logLevelInform, fmt, "inf", ##__VA_ARGS__)
#define printdebug(fmt, ...) printf_common(logLevelDebug, fmt, "dbg", ##__VA_ARGS__)
#define printtrace(fmt, ...) printf_common(logLevelTrace, fmt, "tra", ##__VA_ARGS__)

#define logfatal(fmt, ...) printffatal(fmt, ##__VA_ARGS__)
#define logerror(fmt, ...) printerror(fmt, ##__VA_ARGS__)
#define logwarn(fmt, ...) printwarn(fmt, ##__VA_ARGS__)
#define loginform(fmt, ...) printinform(fmt, ##__VA_ARGS__)
#define logdebug(fmt, ...) printdebug(fmt, ##__VA_ARGS__)
#define logtrace(fmt, ...) printtrace(fmt, ##__VA_ARGS__)
#else
void logerror(char *format, ...);
void logdebug(char *format, ...);
#endif
#endif
